<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .sty1{
            border:1px silver solid; 
            display: inline-block;
            width: 40px;
            margin-left: 10px;
        }
        .sty2{
            font-size: 14px;
        }
    </style>
</head>
<body>
    <table border="1" align="center">
        <tr>
            <td>账号：</td>
            <td><input type="text" /></td>
        </tr>
        <tr>
            <td>密码：</td>
            <td><input type="password" /></td>
        </tr>
        <tr>
            <td>验证码：</td>
            <td>
                <input type="text" size="1" />
                <span class="sty1"></span>
                <a href="javascript:void(0)" class="sty2">看不清？</a>
            </td>
        </tr>
    </table>
    <script src="./node_modules/axios/dist/axios.js"></script>
    <script>
        window.onload=function(){
            axios.get("http://localhost:3000/code/getValidataCode")
            .then(function(res){
                console.log(res.data.code);
                document.getElementsByClassName("sty1")[0].innerText=res.data.code;
            }).catch(function(err){
                console.log(err);
            });
        }
        document.getElementsByClassName("sty2")[0].onclick=function(){
            axios.get("http://localhost:3000/code/getValidataCode")
            .then(function(res){
                console.log(res.data.code);
                document.getElementsByClassName("sty1")[0].innerText=res.data.code;
            }).catch(function(err){
                console.log(err);
            });
        }
    </script>
</body>
</html>